package action;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import basic.PageInfo;
import basic.QuerySet;
import basic.ResultSet;
import basic.SortInfo;
import common.BaseAction;
import common.dict.CommonDict;
import dicts.PaymentDict;
import dicts.RealmDict;
import entities.TCb;
import interfaces.ICbService;
import net.sf.json.JSONObject;
import util.HttpUtil;
import util.ParameterUtil;
import utils.DateUtil;
import utils.ExcelUtil;
import utils.StringUtil;
import views.VCbCard;

public class CbAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7507534255609348887L;

	private ICbService cbService;

	private TCb cbBean;
	private List<TCb> cbList;
	private List<VCbCard> cbCardList;

	private String cbNo;
	private String cbNos;
	private String crdNo;
	private String bnkNo;
	private String txnNo;
	private String cbType;
	private String cbOrder;
	private String cbCur;
	private Double cbMoney;
	private String cbRef;
	private String cbCard;
	private String cbTime;
	private String cbMark;
	private String cbInfo;
	private Double cbAmount;
	private Double cbAmountTotal;
	private String cbCode;
	private String cbMessage;
	private String cbState;
	private Date cbDate;
	private Date cbDateTop;
	private Date cbDateEnd;
	private String cbCstate;
	private Date cbCdate;
	private Date cbCdateTop;
	private Date cbCdateEnd;
	private String cbRemark;

	private String crdNos;
	private String crdIp;
	private String crdOs;
	private String crdBrowser;
	private String crdFinger;
	private String crdLocale;
	private String crdTiming;
	private String crdCode;
	private String crdBin;
	private String crdType;
	private String crdFake;
	private String crdNumber;
	private String crdExpire;
	private String crdCvv;
	private String crdCfname;
	private String crdClname;
	private String crdCphone;
	private String crdCemail;
	private String crdCcountry;
	private String crdCstate;
	private String crdCcity;
	private String crdCaddr;
	private String crdCzip;
	private String crdHfname;
	private String crdHlname;
	private String crdHphone;
	private String crdHemail;
	private String crdHcountry;
	private String crdHstate;
	private String crdHcity;
	private String crdHaddr;
	private String crdHzip;
	private String crdState;
	private Date crdDate;
	private Date crdDateTop;
	private Date crdDateEnd;
	private String crdRemark;
	
	private Boolean cbSummary = new Boolean(false);
	private Boolean crdJoin = new Boolean(false);

	// 展示对象
	public String show() throws Exception {
		if (!cbService.exist(cbNo)) {
			addActionError("数据不存在");
			return INFO;
		} else {
			cbBean = cbService.fetch(cbNo);
			return SUCCESS;
		}
	}

	// 进入退款审核
	public String editreturn() throws Exception {
		if (!cbService.exist(cbNo)) {
			addActionError("数据不存在");
			return INFO;
		} else {
			cbBean = cbService.fetch(cbNo);
			return SUCCESS;
		}
	}

	// 持久化对象
	public String savereturn() throws Exception {
		JSONObject resultMap = new JSONObject();
		Map<String, String> paramsMap = new HashMap<String, String>();
		paramsMap.put("cbNo", cbNo);
		String returnPath=RealmDict.GATEWAY + "Return";
		if(bnkNo.equals ( "3005" )){
			returnPath="https://www.sdcoolshop.com/Return";
		}
		if(bnkNo.equals ( "3006" )){
			returnPath="https://www.decentemall.com/Return";
		}
		resultMap = JSONObject.fromObject(new HttpUtil().post(returnPath, paramsMap));
		addActionError("返回码[" + resultMap.getString("code") + "]返回信息[" + resultMap.getString("message") + "]");
		return SUCCESS;
	}

	// 进入退款撤销
	public String editcanel() throws Exception {
		if (!cbService.exist(cbNo)) {
			addActionError("数据不存在");
			return INFO;
		} else {
			cbBean = cbService.fetch(cbNo);
			return SUCCESS;
		}
	}

	// 持久化对象
	public String savecanel() throws Exception {
		JSONObject resultMap = new JSONObject();
		Map<String, String> paramsMap = new HashMap<String, String>();
		paramsMap.put("cbNo", cbNo);
		resultMap = JSONObject.fromObject(new HttpUtil().post(RealmDict.GATEWAY + "Canel", paramsMap));
		addActionError("返回码[" + resultMap.getString("code") + "]返回信息[" + resultMap.getString("message") + "]");
		return SUCCESS;
	}

	// 进入拒付撤销
	public String editrevoke() throws Exception {
		if (!cbService.exist(cbNo)) {
			addActionError("数据不存在");
			return INFO;
		} else {
			cbBean = cbService.fetch(cbNo);
			return SUCCESS;
		}
	}

	// 持久化对象
	public String saverevoke() throws Exception {
		JSONObject resultMap = new JSONObject();
		Map<String, String> paramsMap = new HashMap<String, String>();
		paramsMap.put("txnNo", txnNo);
		resultMap = JSONObject.fromObject(new HttpUtil().post(RealmDict.GATEWAY + "Revoke", paramsMap));
		addActionError("返回码[" + resultMap.getString("code") + "]返回信息[" + resultMap.getString("message") + "]");
		return SUCCESS;
	}

	public String listreturn() throws Exception {
		QuerySet<Object> querySet = new QuerySet<Object>();

		HashMap<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("cbNo", StringUtil.split(cbNo));
		paramMap.put("crdNo", crdNo);
		paramMap.put("bnkNo", bnkNo);
		paramMap.put("txnNo", txnNo);
		paramMap.put("cbType", cbType);
		paramMap.put("cbOrder", cbOrder);
		paramMap.put("cbCur", cbCur);
		paramMap.put("cbMoney", cbMoney);
		paramMap.put("cbRef", StringUtil.split(cbRef));
		paramMap.put("cbCard", StringUtil.split(cbCard));
		paramMap.put("cbTime", cbTime);
		paramMap.put("cbMark", cbMark);
		paramMap.put("cbInfo", cbInfo);
		paramMap.put("cbAmount", cbAmount);
		paramMap.put("cbCode", cbCode);
		paramMap.put("cbMessage", cbMessage);
		paramMap.put("cbState", "0");
		paramMap.put("cbDate", ParameterUtil.dateCombin(cbDateTop, cbDateEnd));
		paramMap.put("cbCstate", cbCstate);
		paramMap.put("cbCdate", ParameterUtil.dateCombin(cbCdateTop, cbCdateEnd));
		paramMap.put("cbRemark", cbRemark);

		SortInfo sortInfo = new SortInfo();
		sortInfo.setSortField((StringUtil.isEmpty(sortField)) ? "cbDate" : sortField);
		sortInfo.setSortOrder(sortOrder);

		querySet.setPageInfo(new PageInfo(pageIndex, pageSize));
		querySet.setSortInfo(sortInfo);
		querySet.setParamMap(paramMap);

		ResultSet<TCb> resultSet = cbService.search(querySet);
		cbList = resultSet.getResultList();
		pageInfo = resultSet.getPageInfo();
		return SUCCESS;
	}

	public String listcanel() throws Exception {
		QuerySet<Object> querySet = new QuerySet<Object>();

		HashMap<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("cbNo", StringUtil.split(cbNo));
		paramMap.put("crdNo", crdNo);
		paramMap.put("bnkNo", bnkNo);
		paramMap.put("txnNo", txnNo);
		paramMap.put("cbType", PaymentDict.CB_REFUND);
		paramMap.put("cbOrder", cbOrder);
		paramMap.put("cbCur", cbCur);
		paramMap.put("cbMoney", cbMoney);
		paramMap.put("cbRef", StringUtil.split(cbRef));
		paramMap.put("cbCard", StringUtil.split(cbCard));
		paramMap.put("cbTime", cbTime);
		paramMap.put("cbMark", cbMark);
		paramMap.put("cbInfo", cbInfo);
		paramMap.put("cbAmount", cbAmount);
		paramMap.put("cbCode", cbCode);
		paramMap.put("cbMessage", cbMessage);
		paramMap.put("cbState", "0");
		paramMap.put("cbDate", ParameterUtil.dateCombin(cbDateTop, cbDateEnd));
		paramMap.put("cbCstate", cbCstate);
		paramMap.put("cbCdate", ParameterUtil.dateCombin(cbCdateTop, cbCdateEnd));
		paramMap.put("cbRemark", cbRemark);

		SortInfo sortInfo = new SortInfo();
		sortInfo.setSortField((StringUtil.isEmpty(sortField)) ? "cbDate" : sortField);
		sortInfo.setSortOrder(sortOrder);

		querySet.setPageInfo(new PageInfo(pageIndex, pageSize));
		querySet.setSortInfo(sortInfo);
		querySet.setParamMap(paramMap);

		ResultSet<TCb> resultSet = cbService.search(querySet);
		cbList = resultSet.getResultList();
		pageInfo = resultSet.getPageInfo();
		return SUCCESS;
	}

	public String listrevoke() throws Exception {
		QuerySet<Object> querySet = new QuerySet<Object>();

		HashMap<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("cbNo", StringUtil.split(cbNo));
		paramMap.put("crdNo", crdNo);
		paramMap.put("bnkNo", bnkNo);
		paramMap.put("txnNo", txnNo);
		paramMap.put("cbType", PaymentDict.CB_REFUSE);
		paramMap.put("cbOrder", cbOrder);
		paramMap.put("cbCur", cbCur);
		paramMap.put("cbMoney", cbMoney);
		paramMap.put("cbRef", StringUtil.split(cbRef));
		paramMap.put("cbCard", StringUtil.split(cbCard));
		paramMap.put("cbTime", cbTime);
		paramMap.put("cbMark", cbMark);
		paramMap.put("cbInfo", cbInfo);
		paramMap.put("cbAmount", cbAmount);
		paramMap.put("cbCode", cbCode);
		paramMap.put("cbMessage", cbMessage);
		paramMap.put("cbState", "1");
		paramMap.put("cbDate", ParameterUtil.dateCombin(cbDateTop, cbDateEnd));
		paramMap.put("cbCstate", cbCstate);
		paramMap.put("cbCdate", ParameterUtil.dateCombin(cbCdateTop, cbCdateEnd));
		paramMap.put("cbRemark", cbRemark);

		SortInfo sortInfo = new SortInfo();
		sortInfo.setSortField((StringUtil.isEmpty(sortField)) ? "cbDate" : sortField);
		sortInfo.setSortOrder(sortOrder);

		querySet.setPageInfo(new PageInfo(pageIndex, pageSize));
		querySet.setSortInfo(sortInfo);
		querySet.setParamMap(paramMap);

		ResultSet<TCb> resultSet = cbService.search(querySet);
		cbList = resultSet.getResultList();
		pageInfo = resultSet.getPageInfo();
		return SUCCESS;
	}

	// 列表展示
	public String view() throws Exception {
		QuerySet<Object> querySet = new QuerySet<Object>();

		HashMap<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("cbNo", StringUtil.split(cbNo));
		paramMap.put("crdNo", crdNo);
		paramMap.put("bnkNo", bnkNo);
		paramMap.put("txnNo", txnNo);
		paramMap.put("cbType", cbType);
		paramMap.put("cbOrder", cbOrder);
		paramMap.put("cbCur", cbCur);
		paramMap.put("cbMoney", cbMoney);
		paramMap.put("cbRef", StringUtil.split(cbRef));
		paramMap.put("cbCard", StringUtil.split(cbCard));
		paramMap.put("cbTime", cbTime);
		paramMap.put("cbMark", cbMark);
		paramMap.put("cbInfo", cbInfo);
		paramMap.put("cbAmount", cbAmount);
		paramMap.put("cbCode", cbCode);
		paramMap.put("cbMessage", cbMessage);
		paramMap.put("cbState", cbState);
		paramMap.put("cbDate", ParameterUtil.dateCombin(cbDateTop, cbDateEnd));
		paramMap.put("cbCstate", cbCstate);
		paramMap.put("cbCdate", ParameterUtil.dateCombin(cbCdateTop, cbCdateEnd));
		paramMap.put("cbRemark", cbRemark);
		if (crdJoin) {
			paramMap.put("crdNo", StringUtil.split(crdNo));
			paramMap.put("crdIp", crdIp);
			paramMap.put("crdOs", crdOs);
			paramMap.put("crdBrowser", crdBrowser);
			paramMap.put("crdFinger", crdFinger);
			paramMap.put("crdLocale", crdLocale);
			paramMap.put("crdTiming", crdTiming);
			paramMap.put("crdCode", crdCode);
			paramMap.put("crdBin", crdBin);
			paramMap.put("crdType", crdType);
			paramMap.put("crdFake", crdFake);
			paramMap.put("crdNumber", crdNumber);
			paramMap.put("crdCfname", crdCfname);
			paramMap.put("crdClname", crdClname);
			paramMap.put("crdCphone", crdCphone);
			paramMap.put("crdCemail", crdCemail);
			paramMap.put("crdCcountry", crdCcountry);
			paramMap.put("crdCstate", crdCstate);
			paramMap.put("crdCcity", crdCcity);
			paramMap.put("crdCaddr", crdCaddr);
			paramMap.put("crdCzip", crdCzip);
			paramMap.put("crdHfname", crdHfname);
			paramMap.put("crdHlname", crdHlname);
			paramMap.put("crdHphone", crdHphone);
			paramMap.put("crdHemail", crdHemail);
			paramMap.put("crdHcountry", crdHcountry);
			paramMap.put("crdHstate", crdHstate);
			paramMap.put("crdHcity", crdHcity);
			paramMap.put("crdHaddr", crdHaddr);
			paramMap.put("crdHzip", crdHzip);
			paramMap.put("crdState", crdState);
			paramMap.put("crdDate", ParameterUtil.dateCombin(crdDateTop, crdDateEnd));
			paramMap.put("crdRemark", crdRemark);
		}

		SortInfo sortInfo = new SortInfo();
		sortInfo.setSortField((StringUtil.isEmpty(sortField)) ? "cbDate" : sortField);
		sortInfo.setSortOrder(sortOrder);

		querySet.setPageInfo(new PageInfo(pageIndex, pageSize));
		querySet.setSortInfo(sortInfo);
		querySet.setParamMap(paramMap);

		ResultSet<VCbCard> resultSet = cbService.relate(querySet);
		cbCardList = resultSet.getResultList();
		pageInfo = resultSet.getPageInfo();
		
		if(cbSummary){
			querySet.setPolymerizeInfo("cbAmount");
			cbAmountTotal=cbService.collect(querySet);
		}
		return SUCCESS;
	}

	// 导出数据 查询条件等同于列表查询条件
	public String export() throws Exception {
		QuerySet<Object> querySet = new QuerySet<Object>();

		HashMap<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("cbNo", StringUtil.split(cbNo));
		paramMap.put("crdNo", crdNo);
		paramMap.put("bnkNo", bnkNo);
		paramMap.put("txnNo", txnNo);
		paramMap.put("cbType", cbType);
		paramMap.put("cbOrder", cbOrder);
		paramMap.put("cbCur", cbCur);
		paramMap.put("cbMoney", cbMoney);
		paramMap.put("cbRef", StringUtil.split(cbRef));
		paramMap.put("cbCard", StringUtil.split(cbCard));
		paramMap.put("cbTime", cbTime);
		paramMap.put("cbMark", cbMark);
		paramMap.put("cbInfo", cbInfo);
		paramMap.put("cbAmount", cbAmount);
		paramMap.put("cbCode", cbCode);
		paramMap.put("cbMessage", cbMessage);
		paramMap.put("cbState", cbState);
		paramMap.put("cbDate", ParameterUtil.dateCombin(cbDateTop, cbDateEnd));
		paramMap.put("cbCstate", cbCstate);
		paramMap.put("cbCdate", ParameterUtil.dateCombin(cbCdateTop, cbCdateEnd));
		paramMap.put("cbRemark", cbRemark);

		SortInfo sortInfo = new SortInfo();
		sortInfo.setSortField((StringUtil.isEmpty(sortField)) ? "cbDate" : sortField);
		sortInfo.setSortOrder(sortOrder);

		querySet.setPageInfo(new PageInfo(1, CommonDict.EXPORT_LIMIT));
		querySet.setSortInfo(sortInfo);
		querySet.setParamMap(paramMap);

		ResultSet<TCb> resultSet = cbService.search(querySet);
		cbList = resultSet.getResultList();

		List<String> fieldHead = new ArrayList<String>();
		fieldHead.add("编号");
		fieldHead.add("关联卡号");
		fieldHead.add("收单银行");
		fieldHead.add("关联交易号");
		fieldHead.add("类型");
		fieldHead.add("上送流水号");
		fieldHead.add("上送币种");
		fieldHead.add("上送金额");
		fieldHead.add("返回银行单号");
		fieldHead.add("返回原交易卡号");
		fieldHead.add("返回原交易日期");
		fieldHead.add("返回码");
		fieldHead.add("返回信息");
		fieldHead.add("出账金额");
		fieldHead.add("出账码");
		fieldHead.add("出账信息");
		fieldHead.add("出账状态");
		fieldHead.add("出账日期日期");
		fieldHead.add("出账日期时间");
		fieldHead.add("对账状态");
		fieldHead.add("对账日期日期");
		fieldHead.add("对账日期时间");
		fieldHead.add("备注");

		List<List<String>> fieldData = new ArrayList<List<String>>();

		for (TCb cbBean : cbList) {
			List<String> fieldItem = new ArrayList<String>();
			fieldItem.add(cbBean.getCbNo());
			fieldItem.add(cbBean.getCrdNo());
			fieldItem.add(cbBean.getBnkNo());
			fieldItem.add(cbBean.getTxnNo());
			fieldItem.add(cbBean.getCbType());
			fieldItem.add(cbBean.getCbOrder());
			fieldItem.add(cbBean.getCbCur());
			fieldItem.add(cbBean.getCbMoney().toString());
			fieldItem.add(cbBean.getCbRef());
			fieldItem.add(cbBean.getCbCard());
			fieldItem.add(cbBean.getCbTime());
			fieldItem.add(cbBean.getCbMark());
			fieldItem.add(cbBean.getCbInfo());
			fieldItem.add(cbBean.getCbAmount().toString());
			fieldItem.add(cbBean.getCbCode());
			fieldItem.add(cbBean.getCbMessage());
			fieldItem.add((cbBean.getCbState().equals("0")) ? "无效" : "有效");
			fieldItem.add(DateUtil.format(cbBean.getCbDate(), DateUtil.DATE));
			fieldItem.add(DateUtil.format(cbBean.getCbDate(), DateUtil.TIME));
			fieldItem.add((cbBean.getCbCstate().equals("0")) ? "无效" : "有效");
			fieldItem.add(DateUtil.format(cbBean.getCbCdate(), DateUtil.DATE));
			fieldItem.add(DateUtil.format(cbBean.getCbCdate(), DateUtil.TIME));
			fieldItem.add(cbBean.getCbRemark());

			fieldData.add(fieldItem);
		}

		inputStream = ExcelUtil.excel(fieldHead, fieldData);
		return SUCCESS;
	}

	// 导出视图 查询条件等同于列表查询条件
	public String educe() throws Exception {
		QuerySet<Object> querySet = new QuerySet<Object>();

		HashMap<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("cbNo", StringUtil.split(cbNo));
		paramMap.put("crdNo", crdNo);
		paramMap.put("bnkNo", bnkNo);
		paramMap.put("txnNo", txnNo);
		paramMap.put("cbType", cbType);
		paramMap.put("cbOrder", cbOrder);
		paramMap.put("cbCur", cbCur);
		paramMap.put("cbMoney", cbMoney);
		paramMap.put("cbRef", StringUtil.split(cbRef));
		paramMap.put("cbCard", StringUtil.split(cbCard));
		paramMap.put("cbTime", cbTime);
		paramMap.put("cbMark", cbMark);
		paramMap.put("cbInfo", cbInfo);
		paramMap.put("cbAmount", cbAmount);
		paramMap.put("cbCode", cbCode);
		paramMap.put("cbMessage", cbMessage);
		paramMap.put("cbState", cbState);
		paramMap.put("cbDate", ParameterUtil.dateCombin(cbDateTop, cbDateEnd));
		paramMap.put("cbCstate", cbCstate);
		paramMap.put("cbCdate", ParameterUtil.dateCombin(cbCdateTop, cbCdateEnd));
		paramMap.put("cbRemark", cbRemark);
		if (crdJoin) {
			paramMap.put("crdNo", StringUtil.split(crdNo));
			paramMap.put("crdIp", crdIp);
			paramMap.put("crdOs", crdOs);
			paramMap.put("crdBrowser", crdBrowser);
			paramMap.put("crdFinger", crdFinger);
			paramMap.put("crdLocale", crdLocale);
			paramMap.put("crdTiming", crdTiming);
			paramMap.put("crdCode", crdCode);
			paramMap.put("crdBin", crdBin);
			paramMap.put("crdType", crdType);
			paramMap.put("crdFake", crdFake);
			paramMap.put("crdNumber", crdNumber);
			paramMap.put("crdCfname", crdCfname);
			paramMap.put("crdClname", crdClname);
			paramMap.put("crdCphone", crdCphone);
			paramMap.put("crdCemail", crdCemail);
			paramMap.put("crdCcountry", crdCcountry);
			paramMap.put("crdCstate", crdCstate);
			paramMap.put("crdCcity", crdCcity);
			paramMap.put("crdCaddr", crdCaddr);
			paramMap.put("crdCzip", crdCzip);
			paramMap.put("crdHfname", crdHfname);
			paramMap.put("crdHlname", crdHlname);
			paramMap.put("crdHphone", crdHphone);
			paramMap.put("crdHemail", crdHemail);
			paramMap.put("crdHcountry", crdHcountry);
			paramMap.put("crdHstate", crdHstate);
			paramMap.put("crdHcity", crdHcity);
			paramMap.put("crdHaddr", crdHaddr);
			paramMap.put("crdHzip", crdHzip);
			paramMap.put("crdState", crdState);
			paramMap.put("crdDate", ParameterUtil.dateCombin(crdDateTop, crdDateEnd));
			paramMap.put("crdRemark", crdRemark);
		}

		SortInfo sortInfo = new SortInfo();
		sortInfo.setSortField((StringUtil.isEmpty(sortField)) ? "cbDate" : sortField);
		sortInfo.setSortOrder(sortOrder);
		
		querySet.setPageInfo(new PageInfo(1, CommonDict.EXPORT_LIMIT));
		querySet.setSortInfo(sortInfo);
		querySet.setParamMap(paramMap);

		ResultSet<VCbCard> resultSet = cbService.relate(querySet);
		cbCardList = resultSet.getResultList();

		List<String> fieldHead = new ArrayList<String>();
		fieldHead.add("编号");
		fieldHead.add("关联卡号");
		fieldHead.add("收单银行");
		fieldHead.add("关联交易号");
		fieldHead.add("类型");
		fieldHead.add("上送流水号");
		fieldHead.add("上送币种");
		fieldHead.add("上送金额");
		fieldHead.add("返回银行单号");
		fieldHead.add("返回原交易卡号");
		fieldHead.add("返回原交易日期");
		fieldHead.add("返回码");
		fieldHead.add("返回信息");
		fieldHead.add("入账金额");
		fieldHead.add("入账码");
		fieldHead.add("入账信息");
		fieldHead.add("入账状态");
		fieldHead.add("入账日期日期");
		fieldHead.add("入账日期时间");
		fieldHead.add("对账状态");
		fieldHead.add("对账日期日期");
		fieldHead.add("对账日期时间");
		fieldHead.add("备注");

		fieldHead.add("卡编号");
		fieldHead.add("ip地址");
		fieldHead.add("操作系统");
		fieldHead.add("浏览器");
		fieldHead.add("指纹");
		fieldHead.add("语言");
		fieldHead.add("时区");
		fieldHead.add("ip国家码");
		fieldHead.add("bin国家码");
		fieldHead.add("类型");
		fieldHead.add("伪卡号");
		fieldHead.add("卡号");
		fieldHead.add("收货人firstname");
		fieldHead.add("收货人lastname");
		fieldHead.add("收货人电话");
		fieldHead.add("收货人邮件");
		fieldHead.add("收货人国家");
		fieldHead.add("收货人州/省");
		fieldHead.add("收货人城市");
		fieldHead.add("收货人地址");
		fieldHead.add("收货人邮编");
		fieldHead.add("持卡人firstname");
		fieldHead.add("持卡人lastname");
		fieldHead.add("持卡人电话");
		fieldHead.add("持卡人邮箱");
		fieldHead.add("持卡人国家");
		fieldHead.add("持卡人州/省");
		fieldHead.add("持卡人城市");
		fieldHead.add("持卡人地址");
		fieldHead.add("持卡人邮编");
		fieldHead.add("状态");
		fieldHead.add("日期日期");
		fieldHead.add("日期时间");
		fieldHead.add("备注");

		List<List<String>> fieldData = new ArrayList<List<String>>();

		for (VCbCard cbCardBean : cbCardList) {
			List<String> fieldItem = new ArrayList<String>();
			fieldItem.add(cbCardBean.getCbNo());
			fieldItem.add(cbCardBean.getCrdNo());
			fieldItem.add(cbCardBean.getBnkNo());
			fieldItem.add(cbCardBean.getTxnNo());
			fieldItem.add(cbCardBean.getCbType());
			fieldItem.add(cbCardBean.getCbOrder());
			fieldItem.add(cbCardBean.getCbCur());
			fieldItem.add(cbCardBean.getCbMoney().toString());
			fieldItem.add(cbCardBean.getCbRef());
			fieldItem.add(cbCardBean.getCbCard());
			fieldItem.add(cbCardBean.getCbTime());
			fieldItem.add(cbCardBean.getCbMark());
			fieldItem.add(cbCardBean.getCbInfo());
			fieldItem.add(cbCardBean.getCbAmount().toString());
			fieldItem.add(cbCardBean.getCbCode());
			fieldItem.add(cbCardBean.getCbMessage());
			fieldItem.add((cbCardBean.getCbState().equals("0")) ? "无效" : "有效");
			fieldItem.add(DateUtil.format(cbCardBean.getCbDate(), DateUtil.DATE));
			fieldItem.add(DateUtil.format(cbCardBean.getCbDate(), DateUtil.TIME));
			fieldItem.add((cbCardBean.getCbCstate().equals("0")) ? "无效" : "有效");
			fieldItem.add(DateUtil.format(cbCardBean.getCbCdate(), DateUtil.DATE));
			fieldItem.add(DateUtil.format(cbCardBean.getCbCdate(), DateUtil.TIME));
			fieldItem.add(cbCardBean.getCbRemark());

			fieldItem.add(cbCardBean.getCrdNo());
			fieldItem.add(cbCardBean.getCrdIp());
			fieldItem.add(cbCardBean.getCrdOs());
			fieldItem.add(cbCardBean.getCrdBrowser());
			fieldItem.add(cbCardBean.getCrdFinger());
			fieldItem.add(cbCardBean.getCrdLocale());
			fieldItem.add(cbCardBean.getCrdTiming());
			fieldItem.add(cbCardBean.getCrdCode());
			fieldItem.add(cbCardBean.getCrdBin());
			fieldItem.add(cbCardBean.getCrdType());
			fieldItem.add(cbCardBean.getCrdFake());
			fieldItem.add(cbCardBean.getCrdNumber());
			fieldItem.add(cbCardBean.getCrdCfname());
			fieldItem.add(cbCardBean.getCrdClname());
			fieldItem.add(cbCardBean.getCrdCphone());
			fieldItem.add(cbCardBean.getCrdCemail());
			fieldItem.add(cbCardBean.getCrdCcountry());
			fieldItem.add(cbCardBean.getCrdCstate());
			fieldItem.add(cbCardBean.getCrdCcity());
			fieldItem.add(cbCardBean.getCrdCaddr());
			fieldItem.add(cbCardBean.getCrdCzip());
			fieldItem.add(cbCardBean.getCrdHfname());
			fieldItem.add(cbCardBean.getCrdHlname());
			fieldItem.add(cbCardBean.getCrdHphone());
			fieldItem.add(cbCardBean.getCrdHemail());
			fieldItem.add(cbCardBean.getCrdHcountry());
			fieldItem.add(cbCardBean.getCrdHstate());
			fieldItem.add(cbCardBean.getCrdHcity());
			fieldItem.add(cbCardBean.getCrdHaddr());
			fieldItem.add(cbCardBean.getCrdHzip());
			fieldItem.add((cbCardBean.getCrdState().equals("0")) ? "无效" : "有效");
			fieldItem.add(DateUtil.format(cbCardBean.getCrdDate(), DateUtil.DATE));
			fieldItem.add(DateUtil.format(cbCardBean.getCrdDate(), DateUtil.TIME));
			fieldItem.add(cbCardBean.getCrdRemark());
			fieldData.add(fieldItem);
		}

		inputStream = ExcelUtil.excel(fieldHead, fieldData);
		return SUCCESS;
	}

	////////////////////// ---------------------------//////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////// ---------------------------//////////////////////////////////////////////////////////////////////////////////////////////////////////////
	////////////////////// ---------------------------//////////////////////////////////////////////////////////////////////////////////////////////////////////////

	public ICbService getCbService() {
		return cbService;
	}

	public void setCbService(ICbService cbService) {
		this.cbService = cbService;
	}

	public TCb getCbBean() {
		return cbBean;
	}

	public void setCbBean(TCb cbBean) {
		this.cbBean = cbBean;
	}

	public List<TCb> getCbList() {
		return cbList;
	}

	public void setCbList(List<TCb> cbList) {
		this.cbList = cbList;
	}

	public String getCbNo() {
		return cbNo;
	}

	public void setCbNo(String cbNo) {
		this.cbNo = cbNo;
	}

	public String getCbNos() {
		return cbNos;
	}

	public void setCbNos(String cbNos) {
		this.cbNos = cbNos;
	}

	public String getCrdNo() {
		return crdNo;
	}

	public void setCrdNo(String crdNo) {
		this.crdNo = crdNo;
	}

	public String getBnkNo() {
		return bnkNo;
	}

	public void setBnkNo(String bnkNo) {
		this.bnkNo = bnkNo;
	}

	public String getTxnNo() {
		return txnNo;
	}

	public void setTxnNo(String txnNo) {
		this.txnNo = txnNo;
	}

	public String getCbType() {
		return cbType;
	}

	public void setCbType(String cbType) {
		this.cbType = cbType;
	}

	public String getCbOrder() {
		return cbOrder;
	}

	public void setCbOrder(String cbOrder) {
		this.cbOrder = cbOrder;
	}

	public String getCbCur() {
		return cbCur;
	}

	public void setCbCur(String cbCur) {
		this.cbCur = cbCur;
	}

	public Double getCbMoney() {
		return cbMoney;
	}

	public void setCbMoney(Double cbMoney) {
		this.cbMoney = cbMoney;
	}

	public String getCbRef() {
		return cbRef;
	}

	public void setCbRef(String cbRef) {
		this.cbRef = cbRef;
	}

	public String getCbCard() {
		return cbCard;
	}

	public void setCbCard(String cbCard) {
		this.cbCard = cbCard;
	}

	public String getCbTime() {
		return cbTime;
	}

	public void setCbTime(String cbTime) {
		this.cbTime = cbTime;
	}

	public String getCbMark() {
		return cbMark;
	}

	public void setCbMark(String cbMark) {
		this.cbMark = cbMark;
	}

	public String getCbInfo() {
		return cbInfo;
	}

	public void setCbInfo(String cbInfo) {
		this.cbInfo = cbInfo;
	}

	public Double getCbAmount() {
		return cbAmount;
	}

	public void setCbAmount(Double cbAmount) {
		this.cbAmount = cbAmount;
	}

	public String getCbCode() {
		return cbCode;
	}

	public void setCbCode(String cbCode) {
		this.cbCode = cbCode;
	}

	public String getCbMessage() {
		return cbMessage;
	}

	public void setCbMessage(String cbMessage) {
		this.cbMessage = cbMessage;
	}

	public String getCbState() {
		return cbState;
	}

	public void setCbState(String cbState) {
		this.cbState = cbState;
	}

	public Date getCbDate() {
		return cbDate;
	}

	public void setCbDate(Date cbDate) {
		this.cbDate = cbDate;
	}

	public Date getCbDateTop() {
		return cbDateTop;
	}

	public void setCbDateTop(Date cbDateTop) {
		this.cbDateTop = cbDateTop;
	}

	public Date getCbDateEnd() {
		return cbDateEnd;
	}

	public void setCbDateEnd(Date cbDateEnd) {
		this.cbDateEnd = cbDateEnd;
	}

	public String getCbCstate() {
		return cbCstate;
	}

	public void setCbCstate(String cbCstate) {
		this.cbCstate = cbCstate;
	}

	public Date getCbCdate() {
		return cbCdate;
	}

	public void setCbCdate(Date cbCdate) {
		this.cbCdate = cbCdate;
	}

	public Date getCbCdateTop() {
		return cbCdateTop;
	}

	public void setCbCdateTop(Date cbCdateTop) {
		this.cbCdateTop = cbCdateTop;
	}

	public Date getCbCdateEnd() {
		return cbCdateEnd;
	}

	public void setCbCdateEnd(Date cbCdateEnd) {
		this.cbCdateEnd = cbCdateEnd;
	}

	public String getCbRemark() {
		return cbRemark;
	}

	public void setCbRemark(String cbRemark) {
		this.cbRemark = cbRemark;
	}

	public List<VCbCard> getCbCardList() {
		return cbCardList;
	}

	public void setCbCardList(List<VCbCard> cbCardList) {
		this.cbCardList = cbCardList;
	}

	public Boolean getCrdJoin() {
		return crdJoin;
	}

	public void setCrdJoin(Boolean crdJoin) {
		this.crdJoin = crdJoin;
	}

	public String getCrdNos() {
		return crdNos;
	}

	public void setCrdNos(String crdNos) {
		this.crdNos = crdNos;
	}

	public String getCrdIp() {
		return crdIp;
	}

	public void setCrdIp(String crdIp) {
		this.crdIp = crdIp;
	}

	public String getCrdOs() {
		return crdOs;
	}

	public void setCrdOs(String crdOs) {
		this.crdOs = crdOs;
	}

	public String getCrdBrowser() {
		return crdBrowser;
	}

	public void setCrdBrowser(String crdBrowser) {
		this.crdBrowser = crdBrowser;
	}

	public String getCrdFinger() {
		return crdFinger;
	}

	public void setCrdFinger(String crdFinger) {
		this.crdFinger = crdFinger;
	}

	public String getCrdLocale() {
		return crdLocale;
	}

	public void setCrdLocale(String crdLocale) {
		this.crdLocale = crdLocale;
	}

	public String getCrdTiming() {
		return crdTiming;
	}

	public void setCrdTiming(String crdTiming) {
		this.crdTiming = crdTiming;
	}

	public String getCrdCode() {
		return crdCode;
	}

	public void setCrdCode(String crdCode) {
		this.crdCode = crdCode;
	}

	public String getCrdBin() {
		return crdBin;
	}

	public void setCrdBin(String crdBin) {
		this.crdBin = crdBin;
	}

	public String getCrdType() {
		return crdType;
	}

	public void setCrdType(String crdType) {
		this.crdType = crdType;
	}

	public String getCrdFake() {
		return crdFake;
	}

	public void setCrdFake(String crdFake) {
		this.crdFake = crdFake;
	}

	public String getCrdNumber() {
		return crdNumber;
	}

	public void setCrdNumber(String crdNumber) {
		this.crdNumber = crdNumber;
	}

	public String getCrdExpire() {
		return crdExpire;
	}

	public void setCrdExpire(String crdExpire) {
		this.crdExpire = crdExpire;
	}

	public String getCrdCvv() {
		return crdCvv;
	}

	public void setCrdCvv(String crdCvv) {
		this.crdCvv = crdCvv;
	}

	public String getCrdCfname() {
		return crdCfname;
	}

	public void setCrdCfname(String crdCfname) {
		this.crdCfname = crdCfname;
	}

	public String getCrdClname() {
		return crdClname;
	}

	public void setCrdClname(String crdClname) {
		this.crdClname = crdClname;
	}

	public String getCrdCphone() {
		return crdCphone;
	}

	public void setCrdCphone(String crdCphone) {
		this.crdCphone = crdCphone;
	}

	public String getCrdCemail() {
		return crdCemail;
	}

	public void setCrdCemail(String crdCemail) {
		this.crdCemail = crdCemail;
	}

	public String getCrdCcountry() {
		return crdCcountry;
	}

	public void setCrdCcountry(String crdCcountry) {
		this.crdCcountry = crdCcountry;
	}

	public String getCrdCstate() {
		return crdCstate;
	}

	public void setCrdCstate(String crdCstate) {
		this.crdCstate = crdCstate;
	}

	public String getCrdCcity() {
		return crdCcity;
	}

	public void setCrdCcity(String crdCcity) {
		this.crdCcity = crdCcity;
	}

	public String getCrdCaddr() {
		return crdCaddr;
	}

	public void setCrdCaddr(String crdCaddr) {
		this.crdCaddr = crdCaddr;
	}

	public String getCrdCzip() {
		return crdCzip;
	}

	public void setCrdCzip(String crdCzip) {
		this.crdCzip = crdCzip;
	}

	public String getCrdHfname() {
		return crdHfname;
	}

	public void setCrdHfname(String crdHfname) {
		this.crdHfname = crdHfname;
	}

	public String getCrdHlname() {
		return crdHlname;
	}

	public void setCrdHlname(String crdHlname) {
		this.crdHlname = crdHlname;
	}

	public String getCrdHphone() {
		return crdHphone;
	}

	public void setCrdHphone(String crdHphone) {
		this.crdHphone = crdHphone;
	}

	public String getCrdHemail() {
		return crdHemail;
	}

	public void setCrdHemail(String crdHemail) {
		this.crdHemail = crdHemail;
	}

	public String getCrdHcountry() {
		return crdHcountry;
	}

	public void setCrdHcountry(String crdHcountry) {
		this.crdHcountry = crdHcountry;
	}

	public String getCrdHstate() {
		return crdHstate;
	}

	public void setCrdHstate(String crdHstate) {
		this.crdHstate = crdHstate;
	}

	public String getCrdHcity() {
		return crdHcity;
	}

	public void setCrdHcity(String crdHcity) {
		this.crdHcity = crdHcity;
	}

	public String getCrdHaddr() {
		return crdHaddr;
	}

	public void setCrdHaddr(String crdHaddr) {
		this.crdHaddr = crdHaddr;
	}

	public String getCrdHzip() {
		return crdHzip;
	}

	public void setCrdHzip(String crdHzip) {
		this.crdHzip = crdHzip;
	}

	public String getCrdState() {
		return crdState;
	}

	public void setCrdState(String crdState) {
		this.crdState = crdState;
	}

	public Date getCrdDate() {
		return crdDate;
	}

	public void setCrdDate(Date crdDate) {
		this.crdDate = crdDate;
	}

	public Date getCrdDateTop() {
		return crdDateTop;
	}

	public void setCrdDateTop(Date crdDateTop) {
		this.crdDateTop = crdDateTop;
	}

	public Date getCrdDateEnd() {
		return crdDateEnd;
	}

	public void setCrdDateEnd(Date crdDateEnd) {
		this.crdDateEnd = crdDateEnd;
	}

	public String getCrdRemark() {
		return crdRemark;
	}

	public void setCrdRemark(String crdRemark) {
		this.crdRemark = crdRemark;
	}

	public Double getCbAmountTotal() {
		return cbAmountTotal;
	}

	public void setCbAmountTotal(Double cbAmountTotal) {
		this.cbAmountTotal = cbAmountTotal;
	}

	public Boolean getCbSummary() {
		return cbSummary;
	}

	public void setCbSummary(Boolean cbSummary) {
		this.cbSummary = cbSummary;
	}

	
	
}
